﻿<!DOCTYPE html>
<html>
	<meta charset="UTF-8"/>
	<head>
		<script>
			//简易的计算器
			/* 加法 */
			function test(){
				var n1 = num01.value;
				var n2 = num02.value;
				var s = sign.value;
				
				switch(s){
					case "+" : result.value = +n1 + +n2; break; 
					case "-" : result.value = +n1 - +n2; break; 
					case "*" : result.value = +n1 * +n2; break; 
					case "/" : result.value = +n1 / +n2; break; 
					case "%" : result.value = +n1 % +n2; break; 
				}
				
			}
		</script>
	</head>
	<body>
		<p>
		<input id="num01" type="text"/>
		<select id="sign">
			<option value="+">加法</option>
			<option value="-">减法</option>
			<option value="*">乘法</option>
			<option value="/">除法</option>
			<option value="%">取模</option>
		</select>
		<input id="num02" type="text" />
		<button onclick="test()">计算</button>
		</p>
		结果: <input id="result" type="text" />
		
	
		
	</body>	
</html>











